/**
 * common/base
 */

import Vue from 'vue';
import moment from 'moment';
import VueRouter from 'vue-router';
import ElementUI from 'element-ui';
import VModel from 'v-model';
// import Print from '../services/print';

// Vue.use(Print); // 注册

import VueBarcode from '@xkeshi/vue-barcode';

Vue.component(VueBarcode.name, VueBarcode);

// plugins
Vue.use(VueRouter);
Vue.use(ElementUI);
Vue.use(VModel);

// extend VModel
VModel.prototype.$clone = function() {
    const Model = this.constructor;

    return new Model(this);
};

// inner components
import Uploader from '../components/uploader';

Vue.component('Uploader', Uploader);

// inner filters
import qnUrl from '../filters/qn-url';
import qnImg from '../filters/qn-img';
import date from '../filters/date';
import json from '../filters/json';

Vue.filter('qnUrl', qnUrl);
Vue.filter('qnImg', qnImg);
Vue.filter('date', date);
Vue.filter('json', json);

// Alias
Object.assign(Vue.prototype, {
    $showTips(...args) {
        return this.$message.info(...args);
    },
    $showError(...args) {
        return this.$message.error(...args);
    }
});

// debug
if(process.env.NODE_ENV === 'development') {
    window.EUI = ElementUI;
    window.moment = moment;
}
